﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.views.components.computerdisplay {
    import reprise.ui.*;
    import reprise.events.*;
    import flash.display.*;
    import reprise.controls.*;
    import net.wooga.pets.views.*;
    import net.wooga.pets.utils.*;

    public class PetBox extends reprise.controls.SimpleButton {

        private var _index:int;
        private var _needsRoomsLabel:String;
        private var _rewardsLabel:String;
        private var _coins:int;
        private var _xp:int;
        private var _petType:String;
        private var _duration:int;
        private var _missingRoomTypes:Array;
        private var _minLevelReached:Boolean;
        private var _diseaseName:String;
        private var _petAnimation:MovieClip;
        private var _treatments:Array;
        private var _minLevel:String;
        private var _diseaseId:int;
        private var _durationLabel:String;
        private var _buildNowButtonLabel:String;
        private var _needsLabel:String;
        private var _name:String;
        private var _buildButton:LabelButton;
        private var _durationType:String;
        private var _petAnimationDisplay:UIComponent;
        private var _animationSWFUrl:String;
        private var _animationState:String;
        private var _rewardType:String;
        private var _numberOfRewards:String;
        private var _showGemReward:Boolean;// = false

        private static const DURATION_TYPE_SMALL:int = 240;
        private static const DURATION_TYPE_MEDIUM:int = 720;

        public function PetBox(_arg1:PetBoxDisplayData){
            this._index = _arg1.index;
            this._needsLabel = _arg1.needsLabel;
            this._needsRoomsLabel = _arg1.needsRoomsLabel;
            this._rewardsLabel = _arg1.rewardsLabel;
            this._diseaseName = _arg1.diseaseName;
            this._coins = _arg1.coins;
            this._xp = _arg1.xp;
            this._petType = _arg1.petType;
            this._duration = _arg1.duration;
            this._durationLabel = _arg1.durationLabel;
            this._missingRoomTypes = _arg1.missingRoomTypes;
            this._treatments = _arg1.treatments;
            this._minLevelReached = _arg1.hasMinLevel;
            this._minLevel = _arg1.minLevelLabel;
            this._diseaseId = _arg1.diseaseId;
            this._buildNowButtonLabel = _arg1.buildNowButtonLabel;
            this._name = _arg1.name;
            this._animationSWFUrl = _arg1.animationSWFUrl;
            this._rewardType = _arg1.rewardIcon;
            this._numberOfRewards = _arg1.numberOfRewards;
            if (this._duration <= DURATION_TYPE_SMALL){
                this._durationType = "s";
            } else {
                if ((((this._duration > DURATION_TYPE_SMALL)) && ((this._duration <= DURATION_TYPE_MEDIUM)))){
                    this._durationType = "m";
                } else {
                    this._durationType = "l";
                };
            };
        }
        public function get animationSWFUrl():String{
            return (this._animationSWFUrl);
        }
        override protected function initialize():void{
            addCSSClass("petBox");
            super.initialize();
        }
        override protected function createChildren():void{
            var _local1:String;
            var _local3:UIComponent;
            var _local4:MovieClip;
            var _local5:String;
            var _local7:UIComponent;
            var _local8:UIComponent;
            if ((this.index % 2) != 0){
                addCSSClass("right");
                setStyle("marginLeft", "15px");
            };
            addComponent("boxBackground");
            this._petAnimationDisplay = addComponent("petAnimationDisplay");
            RepriseUtils.addLabel(this, "myriadProFont needsLabel", this._needsLabel);
            var _local2:UIComponent = addComponent("roomIconsDisplay");
            for each (_local5 in this._treatments) {
                _local3 = _local2.addComponent("roomIconClipDisplay");
                _local1 = ("Logo" + _local5);
                _local4 = AssetsLibrary.getMovieClip(_local1);
                AssetsLibrary.getMovieClip(_local1).scaleX = (_local4.scaleY = 0.16);
                _local3.addChild(_local4);
            };
            RepriseUtils.addLabel(this, "myriadProFont rewardLabel", this._rewardsLabel);
            RepriseUtils.addLabel(this, "myriadProFont coinsLabel", String(this._coins));
            RepriseUtils.addLabel(this, "myriadProFont xpLabel", String(this._xp));
            RepriseUtils.addComponent(this, "line");
            if (this.showGemReward){
                _local7 = RepriseUtils.addComponent(this, (this._rewardType + "Icon rewardIcon"));
                _local7.addEventListener(DisplayEvent.VALIDATION_COMPLETE, this.rewardIcon_validationComplete);
                if (this._rewardType.length >= 2){
                    RepriseUtils.addLabel(this, "myriadProFont numberOfRewardsLabel", this._numberOfRewards);
                };
            };
            RepriseUtils.addLabel(this, "showcardGothicFont petTypeLabel", this._name);
            var _local6 = (this._missingRoomTypes.length > 0);
            if (!this._minLevelReached){
                this.createLevelLocked();
            } else {
                if (_local6){
                    this.createRoomLocked();
                } else {
                    _local8 = RepriseUtils.addComponent(this, ("duration " + this._durationType));
                    RepriseUtils.addLabel(_local8, ("showcardGothicFont durationLabel " + this._durationType), this._durationLabel);
                };
            };
        }
        private function rewardIcon_validationComplete(_arg1:DisplayEvent):void{
            var _local2:UIComponent = UIComponent(_arg1.target);
            _local2.removeEventListener(DisplayEvent.VALIDATION_COMPLETE, this.rewardIcon_validationComplete);
            Displays.correctScaling(_local2, _local2, 22, 22, -1, -1);
        }
        public function addPetAnimation(_arg1:MovieClip):void{
            if (((this._petAnimationDisplay) && (_arg1))){
                this._petAnimation = _arg1;
                this._petAnimationDisplay.addChild(this._petAnimation);
                if (this._animationState == "play"){
                    this._petAnimation.play();
                } else {
                    this._petAnimation.stop();
                };
            };
        }
        private function createLevelLocked():void{
            enabled = false;
            var _local1:UIComponent = addComponent("disabledLayer");
            addComponent("lockWithBlackBorder");
            RepriseUtils.addLabel(this, "showcardGothicFontOutline minLevelLabel", this._minLevel);
        }
        private function createRoomLocked():void{
            var _local2:UIComponent;
            var _local3:String;
            var _local4:MovieClip;
            var _local6:String;
            var _local7:int;
            var _local8:int;
            var _local9:int;
            var _local10:Number;
            enabled = false;
            var _local1:UIComponent = addComponent("disabledLayer");
            RepriseUtils.addLabel(this, "showcardGothicFontOutline needRoomsLabel", this._needsRoomsLabel);
            this._buildButton = RepriseUtils.addLabelButton(this, "buildButton", this._buildNowButtonLabel);
            var _local5:UIComponent = addComponent("missingRoomsIconDisplay");
            for each (_local6 in this._missingRoomTypes) {
                _local2 = _local5.addComponent("missingRoomIconClipDisplay");
                _local3 = ("Logo" + _local6);
                _local4 = AssetsLibrary.getMovieClip(_local3);
                AssetsLibrary.getMovieClip(_local3).scaleX = (_local4.scaleY = 0.3);
                _local2.addChild(_local4);
            };
            _local7 = 36;
            _local8 = 3;
            _local9 = this._missingRoomTypes.length;
            _local10 = ((_local9 * _local7) + ((_local9 - 1) * _local8));
            _local5.setStyle("width", String(_local10));
        }
        public function get index():int{
            return (this._index);
        }
        public function get buildButton():LabelButton{
            return (this._buildButton);
        }
        public function get petType():String{
            return (this._petType);
        }
        public function get diseaseName():String{
            return (this._diseaseName);
        }
        public function playAnimations():void{
            ((this._petAnimation) && (this._petAnimation.play()));
            this._animationState = "play";
        }
        public function stopAnimations():void{
            ((this._petAnimation) && (this._petAnimation.stop()));
            this._animationState = "play";
        }
        public function get diseaseId():int{
            return (this._diseaseId);
        }
        public function get showGemReward():Boolean{
            return (this._showGemReward);
        }
        public function set showGemReward(_arg1:Boolean):void{
            this._showGemReward = _arg1;
        }

    }
}//package net.wooga.pets.views.components.computerdisplay 
